<?php
/**
 * 用户质押
 */
namespace app\common\model;

use think\Model;
use app\api\model\BaseConfig as BaseConfigModel;

class MemberPledge extends Model
{
    protected $name = 'member_pledge';

    /**
     * 用户质押信息
     */
    public static function memberPledge($mid){

        $pledge_cid = BaseConfigModel::config_data('pledge_cid');
        $release_cid = BaseConfigModel::config_data('pledge_release_cid');

        $data = self::where('mid',$mid)->where('cid',$pledge_cid)->find();

        if(empty($data)){

            $data = [
                'mid'   =>  $mid,
                'cid'   =>  $pledge_cid,
                'money'   =>  0,
                'release'   =>  0,
                'release_cid'   =>  $release_cid,
                'add_time'  =>  date('Y-m-d H:i:s',time())
            ];
            $id = self::insertGetId($data);
            $data['id'] = $id;

        }
        return $data;
    }

}